package ch.zbw.timeline.service;

import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

import javax.swing.text.JTextComponent;

/**
 * Service for printing documents
 * 
 * @author Daniel Stefanovic
 * @version 19.01.2012
 *
 */
public class ZbwPrintService implements PrintService {
	
	/*
	 * (non-Javadoc)
	 * @see ch.zbw.timeline.service.PrintService#print(javax.swing.text.JTextComponent)
	 */
	@Override
	public void print(JTextComponent text) throws PrinterException{
		
		PrinterJob printJob = PrinterJob.getPrinterJob();
		TextPrintable printable = new TextPrintable();
		printable.setText(text);
		
	    if ( printJob.printDialog() == false )  return;
	    
	    printJob.setPrintable(printable);
	    printJob.print();
	}

    
}